#include "common.hpp"

int main()
{
    umask(0);
    int signal = mkfifo(fifo_file.c_str(),mode);
    if(signal != 0)
    {
        cout << errno  << strerror(errno) << endl;
        return 1;
    }
    int fd = open(fifo_file.c_str(),O_RDONLY,0666);
    if(fd == -1)
    {
        cout << "文件打开失败"<< errno << strerror(errno) ;
        return -1;
    }
    cout << "准备通信 我的pid是:" <<getpid()<<endl;
    while(true)
    {
        char buffer[1024] = {0};
        int count = read(fd,buffer,sizeof(buffer)-1);
        if(count > 0)
        {
            cout << buffer <<endl;
        }
        else if(count == 0)
        {
            break;
        }
        else
        {
            break;
        }
    }

    unlink("./fifo");
    return 0;
}
